export const mixins = {
  data() {
    var checkPrice = (rule, value,callback) => {
      if((this.form.price<50&&this.form.price != 0)||this.form.price>1000000000||this.form.price<0||(this.form.price==''&&typeof(this.form.price)=='string')){
        return callback(new Error(this.$t('formRule.prace_rule')));
      } else {
        callback()
      }
    };
    var checkCreator = (rule, value, callback) => {
      if (!this.form.creatorId) {
        return callback(new Error(this.$t('formRule.creator_rule')));
      } else {
        callback()
      }
    };
    var checkStartDate = (rule, value, callback) => {
      if (!this.form.saleStartTime) {
        return callback(new Error(this.$t('formRule.time_rule')));
      } else {
        callback()
      }
    };
    var checkEndDate = (rule, value, callback) => {
      if (!this.form.saleEndTime) {
        return callback(new Error(this.$t('formRule.time_rule')));
      } else {
        callback()
      }
    };
    var checkPreDate = (rule, value, callback) => {
      if (!this.form.preSaleTime) {
        return callback(new Error(this.$t('formRule.time_rule')));
      } else {
        callback()
      }
    };
    var checkImg = (rule, value, callback) => {
      if (!this.form.thumbnailId) {
        return callback(new Error(this.$t('formRule.poster_rule')));
      } else {
        callback()
      }
    };
    var checkFile = (rule, value, callback) => {
      if (!this.form.fileId) {
        return callback(new Error(this.$t('formRule.file_rule')));
      } else {
        callback()
      }
    };
    var zh_TW = (rule,value,callback) => {
      if (!this.form.name.zh_TW) {
        return callback(new Error(this.$t('formRule.arttnMovieName')));
      } else {
        callback()
      }
    };
    var en_US = (rule,value,callback) => {
      if (!this.form.name.en_US) {
        return callback(new Error(this.$t('formRule.artusMovieName')));
      } else {
        callback()
      }
    };
    var ja_JP = (rule,value,callback) => {
      if (!this.form.name.ja_JP) {
        return callback(new Error(this.$t('formRule.artjaMovieName')));
      } else {
        callback()
      }
    };
    var zh_CN = (rule,value,callback) => {
      if (!this.form.name.zh_CN) {
        return callback(new Error(this.$t('formRule.artcnMovieName')));
      } else {
        callback()
      }
    };
    var d_zh_TW = (rule,value,callback) => {
      if (!this.form.description.zh_TW) {
        return callback(new Error(this.$t('formRule.inputPlaceholder')));
      } else {
        callback()
      }
    };
    var d_en_US = (rule,value,callback) => {
      if (!this.form.description.en_US) {
        return callback(new Error(this.$t('formRule.inputPlaceholder')));
      } else {
        callback()
      }
    };
    var d_ja_JP = (rule,value,callback) => {
      if (!this.form.description.ja_JP) {
        return callback(new Error(this.$t('formRule.inputPlaceholder')));
      } else {
        callback()
      }
    };
    var d_zh_CN = (rule,value,callback) => {
      if (!this.form.description.zh_CN) {
        return callback(new Error(this.$t('formRule.inputPlaceholder')));
      } else {
        callback()
      }
    };
    return {
      mode: "add",
      theatredKey: '',
      theatreKey: '',
      theatredList: [],
      selectAllTheatred: false,
      selectedNum: 0,
      showTheatre: false,
      isEdit: false,
      showImg: false,
      uploadFileStatus: false,
      uploadingNum: 1,
      pngBlob: [],
      pngIndex: 0,
      showFileDialog: false,
      modelValue: false,
      showUpload: true,
      scDialogFileData: {
        isDIY: false,
        isDefense: true,
        isUploadedFile: false,//是否已上传
        isPreview: false,
        uploadResponse: '',
        uploadFiles: '',
        imgFiles: [],
        imgPreviewFiles: [],
        page: 3,
        compression: true,
        file: '',
        previewFile: '',
        newImg: ''
      },
      scDialogData: {
        isUploaded: false,//是否已上传
        thumbnailUrl: '',
        isDefense: true,
        newImg: '',
        compression: true,
        posterImg: '',
        uploadResponse: '',
        uploadFiles: '',
        files: ''
      },
      disabled: false,
      creatorIdList: [],
      localeList: [
        {
          country: 'ALL',
          en_US: 'ALL',
          ja_JP: '全て',
          zh_CN: '全部',
          zh_TW: '全部',
        }
        // {
        // 	name: this.$t('artwork_data.locale_japan'),
        // 	value: 0,
        // },
        // {
        // 	name: this.$t('artwork_data.locale_world'),
        // 	value: 1,
        // }
      ],
      langList: [
        {
          name: '简体中文',
          value: 'zh_CN',
        },
        {
          name: '繁體中文',
          value: 'zh_TW',
        },
        {
          name: 'English',
          value: 'en_US',
        },
        {
          name: '日本語',
          value: 'ja_JP',
        }
      ],
      powerList: [
        { 
          name: this.$t('artwork_data.form.power.type1'),
          value: 1||0,
        },
        {
          name: this.$t('artwork_data.form.power.type2'),
          value: 2,
        },
        {
          name: this.$t('artwork_data.form.power.type3'),
          value: 3,
        },
        { 
          name: this.$t('artwork_data.form.power.type4'),
          value: 4,
        },
        {
          name: this.$t('artwork_data.form.power.type5'),
          value: 5,
        },
        {
          name: this.$t('artwork_data.form.power.type6'),
          value: 6,
        }
      ],
      onlyList: [
        { 
          name: 'unique work',
          value: 'unique work',
        },
        {
          name: 'non unique work',
          value: 'non unique work',
        },
        {
          name: 'unknown',
          value: 'unknown',
        }
      ],
      typeList: [
        {
          name: this.$t('artwork_data.form.tcType.number'),
          value: 1,
        },
        {
          name: this.$t('artwork_data.form.tcType.body'),
          value: 2,
        }
      ],
      statusList: [
        {
          name: this.$t('artwork_data.statusType.status1'),
          value: 1,
        },
        {
          name: this.$t('artwork_data.statusType.status2'),
          value: 2,
        },
        {
          name: this.$t('artwork_data.statusType.status3'),
          value: 3,
        },
        {
          name: this.$t('artwork_data.statusType.status4'),
          value: 4,
        }
      ],
      classList: [
        {
          name: this.$t('artwork_data.classification.class1'),
          value: 11,
        },
        {
          name: this.$t('artwork_data.classification.class2'),
          value: 12,
        },
        {
          name: this.$t('artwork_data.classification.class3'),
          value: 13,
        },
        {
          name: this.$t('artwork_data.classification.class4'),
          value: 14,
        },
        {
          name: this.$t('artwork_data.classification.class5'),
          value: 21,
        },
        {
          name: this.$t('artwork_data.classification.class7'),
          value: 15,
        },
        {
          name: this.$t('artwork_data.classification.class6'),
          value: 29,
        }
      ],
      currencyType: [
        {
          value: 1,
          name: this.$t('table_data.currency.jpy'),
        },
        {
          value: 2,
          name: this.$t('table_data.currency.dollar'),
        },
        {
          value: 3,
          name: this.$t('table_data.currency.rmb'),
        },
      ],
      titleMap: {
        add: this.$t('table_data.adduserTitle'),
        edit: this.$t('table_data.userTitle')
      },
      locationArr: [{
        value: 'ja',
        label: 'Japanese'
      }, {
        value: 'en',
        label: 'English'
      }, {
        value: 'chs',
        label: '中文简体'
      }, {
        value: 'cht',
        label: '中文繁體'
      }],
      // name: {
      // 	en_US: '',
      // 	ja_JP: '',
      // 	zh_CN: '',
      // 	zh_TW: '',
      // },
      artworkDesc: {
        en_US: '',
        ja_JP: '',
        zh_CN: '',
        zh_TW: '',
      },
      fileAction: 'fileType',
      action: '#',
      image: null,
      file: null,
      theatreList: [],
      theatreListData: [],
      filterMethod(query, item) {
        return item.label.indexOf(query) > -1;
      },
      defaultTime: [new Date(2000,1,1,23,59,59)],
      form: {
        "saleLocale": 'ALL',
        "isEnableResell": 0,
        "artworkId": "",
        "creatorId": "",
        "thumbnailId": null,
        "previewFiles": [],
        "ebookFiles": [],
        "fileId": null,
        "name": {
          en_US: '',
          ja_JP: '',
          zh_CN: '',
          zh_TW: '',
        },
        "description": {
          en_US: '',
          ja_JP: '',
          zh_CN: '',
          zh_TW: '',
        },
        "movieId": null,
        "movieName": null,
        "category": null,
        "fileUrl": null,
        "thumbnailUrl": "",
        "price": null,
        "currency": 1,
        "isTaxIncluded": true,
        "issuesAmount": null,
        "saleStartTime": "",
        "saleEndTime": "",
        "saleMethod": 1,
        "paymentMode": null,
        "serialCodeRequired": false,
        "uniqueness": "",
        "royaltyRate": null,
        "rights": null,
        "certificateName": "",
        "isEnableCertificate": false,
        "isDefense": false,
        "status": null,
        "genre": null
      },
      movieData: [],
      uploadForm: {
        movie_id: '',
        start_date: '',
        end_date: '',
        official_site: '',
        information: '',
        fileUrl: null,
        thumbnailUrl: null,
        title: '',
      },
      rules: {
        "isEnableResell": [
          {required: true,message: this.$t('formRule.selectPlaceholder'),trigger: 'change'}
        ],
        "name.en_US": [
          {required: true, validator: en_US, trigger:'blur'}
        ],
        "name.ja_JP": [
          {required: true, validator: ja_JP, trigger:'blur'}
        ],
        "name.zh_CN": [
          {required: true, validator: zh_CN, trigger:'blur'}
        ],
        "name.zh_TW": [
          {required: true, validator: zh_TW, trigger:'blur'}
        ],
        "description.en_US": [
          {required: true, validator: d_en_US, trigger:'blur'}
        ],
        "description.ja_JP": [
          {required: true, validator: d_ja_JP, trigger:'blur'}
        ],
        "description.zh_CN": [
          {required: true, validator: d_zh_CN, trigger:'blur'}
        ],
        "description.zh_TW": [
          {required: true, validator: d_zh_TW, trigger:'blur'}
        ],
        "status": [
            {required: true, message: this.$t('formRule.selectPlaceholder'),trigger:'change'}
        ],
        "uniqueness": [
            {required: true, message: this.$t('formRule.selectPlaceholder'),trigger:'change'}
        ],
        "price": [
          {required: true, validator: checkPrice,trigger:'blur'}
        ],
        "isTaxIncluded": [
          {required: true, message: this.$t('formRule.endDate_rule'),trigger:'change'}
        ],
        "paymentMode": [
          {required: true, message: this.$t('formRule.pay_rule'),trigger:'change'}
        ],
        "serialCodeRequired": [
          {required: true, message: this.$t('formRule.endDate_rule'),trigger:'change'}
        ],
        "royaltyRate": [
          {required: true, message: this.$t('formRule.tax_rule'),trigger:'change'}
        ],
        "genre": [
          {required: true, message: this.$t('formRule.format_rule'),trigger:'change'}
        ],
        "rights": [
          {required: true, message: this.$t('formRule.pow_rule'),trigger:'change'}
        ],
        "isEnableCertificate": [
          {required: true, message: this.$t('formRule.certificate_rule'),trigger:'change'}
        ],
        "isDefense": [
          {required: true, message: this.$t('formRule.defense_rule'),trigger:'change'}
        ],
        "certificateName": [
          {required: true, message: this.$t('formRule.zmname_rule'),trigger:'change'}
        ],
        "category": [
          {required: true, message: this.$t('formRule.type_rule'),trigger:'change'}
        ],
        "saleStartTime": [
          {required: true, validator: checkStartDate, trigger:'change'}
        ],
        "saleEndTime": [
          {required: true, validator: checkEndDate, trigger:'change'}
        ],
        "preSaleTime": [
          {required: true, validator: checkPreDate, trigger:'change'}
        ],
        "fileId": [
          {required: true, validator: checkFile, trigger:'change'}
        ],
        "thumbnailUrl": [
          {required: true, validator: checkImg, trigger:'change'}
        ],
        "thumbnailId": [
          {required: true, validator: checkImg, trigger:'change'}
        ],
        "creatorId": [
          {required: true, validator: checkCreator, trigger:'change'}
        ]
      },
      visible: false,
      isSaveing: false
    }
  },
  created(){
    
  }
}
